/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.statemachine;

import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;

import com.cea.papyrus.core.editor.DiagramPalette;
import com.cea.papyrus.core.editor.ModelManager;
import com.cea.papyrus.core.editor.abstracteditor.AbstractGraphicalPageWithFlyoutPalette;
import com.cea.papyrus.diagraminterchange2.di2.Diagram;

/**
 * The Class StateMachineEditor.
 * Manages creation of the statemachine diagram editor
 * 
 * @author David Servat
 * @since 29 jan. 07
 */
public class StateMachineEditor extends AbstractGraphicalPageWithFlyoutPalette implements /*DiagramEditorPage,*/ ITabbedPropertySheetPageContributor{

	//Darpan
	public StateMachineEditor() {
		
	}
	
	/**
	 * The PALETTE_ MODEL.
	 */
	private static DiagramPalette PALETTE_MODEL;    

	/**
	 * The channel.
	 */
	private int channel = 501;    

	/**
	 * The Constructor.
	 * 
	 * @param diagram the diagram
	 * @param modelMngr the model mngr
	 */
	public StateMachineEditor(Diagram diagram, ModelManager modelMngr){
		super(diagram, modelMngr);
	}

	/**
	 * Creates a new StateMachineEditor, with a specified editing domain.
	 * @param diagram the diagram displayed by this editor
	 * @param modelMngr the instance of the model manager for the edited model
	 * @param commandStack the command stack shared among all editors of a multiDiagramEditor
	 */
	public StateMachineEditor( Diagram diagram, ModelManager modelMngr, CommandStack commandStack, ActionRegistry actionRegistry){
		super( diagram, modelMngr, commandStack, actionRegistry);
	}

	/**
	 * Configure graphical viewer.
	 */
	protected void configureGraphicalViewer(){

		super.configureGraphicalViewer();

		viewer = getGraphicalViewer();
		//create and register the EditPartFactory

		viewer.setEditPartFactory(new StateMachineGraphicalEditPartsFactory(modelMngr));

		//configure the context menu provider
		cmProvider = new StateMachineContextMenuProvider(viewer, getActionRegistry(),modelMngr);

		super.configureContextMenuProvider();
	}

	/**
	 * In order to obtain the palette Root.
	 * 
	 * @return the palette root
	 */
	protected PaletteRoot getPaletteRoot(){
		if(PALETTE_MODEL == null)
			PALETTE_MODEL = StateMachinePaletteFactory.createPalette();
		return PALETTE_MODEL;
	}
}
